#include<bits/stdc++.h>
using namespace std;

int n, r[100005], r1[100005], cnt, c1, ans;

int main () {
    freopen("duel.in", "r", stdin);
    freopen("duel.out", "w", stdout);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> r[i];
    }
    sort(r + 1, r + n + 1);
    for (int i = 1; i <= n; i++) {
        if (r[i] > r[i - 1]) c1++;
        r1[c1]++;
    }
    for (int i = c1 - 1; i >= 1; i--) {
        if (r1[i] <= r1[i + 1]) cnt += r1[i + 1], ans += r1[i + 1];
        else if (cnt >= r1[i] - r1[i + 1]) cnt -= r1[i] - r1[i + 1], ans += r1[i];
        else if (cnt) ans += r1[i] - r1[i + 1] - cnt, cnt = 0;
        else ans += r1[i], cnt += r1[i];
    }
    cout << ans;
    return 0;
}
